package com.ojoin.trade.supplyloan_core.web.dao.impl;

import com.ojoin.trade.common.exception.BusinessException;
import com.ojoin.trade.common.exception.DaoException;
import com.ojoin.trade.common.web.dao.impl.BaseDaoImpl;
import com.ojoin.trade.supplyloan_core.web.dao.TbRedoDao;
import com.ojoin.trade.supplyloan_core.web.domain.TbRedo;
import org.springframework.stereotype.Repository;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 16-5-10
 * Time: 上午9:28
 * To change this template use File | Settings | File Templates.
 */
@Repository
public class TbRedoDaoImpl extends BaseDaoImpl<TbRedo> implements TbRedoDao {
    @Override
    public TbRedo queryTbReDoByBusinessId(String orderid) throws BusinessException {

        String mapMethodName = "selectByBusinessId";
        try {
            return this.sqlSessionTemplate.selectOne(getSqlName(mapMethodName), orderid);
        } catch (Exception e) {
            throw new DaoException(String.format("根据转账id查询redo记录出错！语句：%s",
                    getSqlName(mapMethodName)), e);
        }


    }

    @Override
    public void updateTbRedo(String orderId) throws BusinessException {

        String methodName="update";
        try{
            this.sqlSessionTemplate.update(getSqlName(methodName),orderId);
        }catch (Exception e){
            throw new DaoException(String.format("根据转账orderid更新记录出错！语句：%s",
                    getSqlName(methodName)), e);
        }
    }

}
